package cn.com.okgo.cookie;

import java.util.List;

import cn.com.okgo.OkGo;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;

/**
 * Created by luwenlong on 2017/8/30.
 */

public class CookiesManager implements CookieJar {

    private final PreferencesCookieStore cookieStore = new PreferencesCookieStore(OkGo.getContext());

    @Override
    public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
        cookieStore.saveCookie(url, cookies);
    }

    @Override
    public List<Cookie> loadForRequest(HttpUrl url) {
        return cookieStore.loadCookie(url);
    }

    public ICookieStore getCookieStore() {
        return cookieStore;
    }
}
